﻿@model MVC_basic.ViewModels.CajaAppViewModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<div id="validationDiv">
        <div class="large-4">
            @Html.LabelFor(model => model.name)
            @Html.EditorFor(model => model.name)
            @Html.ValidationMessageFor(model => model.name)
        </div>
        <div class="large-4">
            @Html.LabelFor(model => model.logoUrl) 
            @Html.EditorFor(model => model.logoUrl)
            @Html.ValidationMessageFor(model => model.logoUrl)
        </div>
        <div class="large-4">
            @Html.LabelFor(model => model.acceptedUrl) 
            @Html.EditorFor(model => model.acceptedUrl)
            @Html.ValidationMessageFor(model => model.acceptedUrl)
        </div>
        <div class="large-4">
            @Html.Label("Upload a zip file")
            <div class="row">
                <div class="large-10 small-8 columns" style="padding:0px;">
                    <input id= "zipUrl" type="text" disabled="disabled"/>
                </div>
                <div class="large-2 small-4 columns">
                    <div class="button small" onclick="getFile()">Browse</div>
                </div>
            </div>
            <div style='height: 0px;width:0px; overflow:hidden;'><input type="file" name="zipfile" id="zipfile" onchange="getZipUrl(this)"/></div>
        </div>

</div>

<script>
    $.validator.unobtrusive.parse('#validationDiv');

    function getFile() {
        document.getElementById("zipfile").click();
    }
    function getZipUrl(obj) {
        var file = obj.value;
        document.getElementById("zipUrl").value = file;
    }
</script>